import { reactive } from "vue";
export default function() {
	const dropDown = reactive({
		character: false,
		account: false,
		help: false,
		nav: false
	})
	// 下拉选择
	function selectHandle(type = 'character') {
		dropDown[type] = !dropDown[type];
		if (dropDown[type]) {
			setTimeout(() => {
				dropDown[type] = true;
				document.addEventListener('click', documentClickEvent);
			}, 100)
		}
	}
	// 注册document点击事件
	function documentClickEvent() {
		for (let key in dropDown) {
			dropDown[key] = false;
		}
		document.removeEventListener('click', documentClickEvent);
	}
	return {
		dropDown,
		selectHandle
	}
}